﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace MishraReader
{
    public struct Hsv
    {
        private readonly double _hue;
        private readonly double _saturation;
        private readonly double _value;

        public Hsv(double hue, double saturation, double value)
        {
            this._hue = hue;
            this._saturation = saturation;
            this._value = value;
        }

        public double Hue
        {
            get { return _hue; }
        }

        public double Saturation
        {
            get { return _saturation; }
        }

        public double Value
        {
            get { return _value; }
        }

        public bool Equals(Hsv other)
        {
            return other._hue.Equals(_hue) && other._saturation.Equals(_saturation) && other._value.Equals(_value);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj))
                return false;
            return obj is Hsv && Equals((Hsv)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                var result = _hue.GetHashCode();
                result = (result*397) ^ _saturation.GetHashCode();
                result = (result*397) ^ _value.GetHashCode();
                return result;
            }
        }

        public static bool operator ==(Hsv h1, Hsv h2)
        {
            return (h1.Hue == h2.Hue && h1.Saturation == h2.Saturation && h1.Value == h2.Value);
        }

        public static bool operator !=(Hsv h1, Hsv h2)
        {
            return !(h1 == h2);
        }
    }
}